import React from 'react';
import { HashRouter, Route, Routes, Navigate } from 'react-router-dom';
import Home from '@/views/Home';
import CustomizeRecordTable from '@/views/CustomizeRecordTable';
import Login from '@/views/Login';
import OSSLogin from '@/views/Login/OSSLogin';

console.log('process.env.NODE_ENV', process.env.TARGET_ENV);

/** 环境区分 */
const ctx = {
	isTEST: process.env.TARGET_ENV?.includes('test'),
	isSSO: process.env.TARGET_ENV?.includes('sso')
};

const Router: React.FC = () => {
	{
		/* 所有的路由配置均在 HashRouter 内部 */
	}
	return (
		<HashRouter>
			<Routes>
				<Route path="/" element={<Home />} />
				{ctx.isTEST && <Route path="/login" element={<Login />} />}
				{ctx.isSSO && <Route path="/osslogin" element={<OSSLogin />} />}
				{/* 重定向到首页 */}
				{ctx.isSSO && <Route path="*" element={<Navigate to="/osslogin" />} />}
				{ctx.isTEST && <Route path="*" element={<Navigate to="/login" />} />}
			</Routes>
		</HashRouter>
	);
};

export default Router;
